const prefix = this.pageObj.getVariables().find(v => v.name === "environmentType")?.value;
const timeline = this.getApiPage().getApiWidgetByAliasName('timelineVertical')?.widgetObj;
const $form = this.getApiPage().getApiWidgetByAliasName('judge-content');
let data = $form?.widgetObj._option.dataSource;
const selfObj = this.widgetObj;
const { dataIndex, value } = $event;
const { instanceName } = selfObj._option;
/**
 * @薛育飞
 *
 * /emergencyRecord/planHandleProcessDetail             事件的记录查询 queryType = "1"
 * /emergencyRecord/queryPlanHandleProcess              处置的记录查询 queryType = "4"
 *
 * /emergencyRecord/queryEmergencyDynamicRecord         应急动态的记录查询 queryType = "2"
 * /emergencyRecord/queryEventStateProcessRecord        事态进度的记录查询 queryType = "3"
 *
 * /emergencyRecord/queryMsgEventStateProcessRecord     消息事件日志的记录查询 queryType = "5"
 * @type {{eventId: string, queryType: string}}
 */
const option = { eventId: '1826240458215018496', queryType: '1' };
option[dataIndex] = value;

const requestPost = (url, body) => {
  const options = {
    method: 'POST',
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(body)
  };
  return fetch(url, options).then(res => res.json())
};

console.log(this, $event);

layui.form.submit(instanceName, (form) => {
  if (data?.id) option.eventId = data.id;
  if (form.field.personName) option.personName = form.field.personName;
  if (form.field.stage) option.stage = form.field.stage;
  if (form.field.trends) option.trends = form.field.trends;
  if (form.field.timeScope) option.timeScope = form.field.timeScope;

  requestPost(`/${prefix}SummaryAssessmentSV/emergencyRecord/planHandleProcessDetailByReq`, option).then(({ result, success }) => {
    if (success && Array.isArray(result)) {
      timeline.dataSource = result;
      timeline.render();
    }
    console.log('事件记录： =》 ', { result, success })
  })
  console.log(form)
})



